PAFilenameList

Inherits From:	PAStringList : Storage : Object

Declared In:	PAFilenameList.h

Class Description

	The PAFilenameList (a subclass of PAStringList) is a convenient way to deal with lists of filenames. It contains methods for generating lists of filenames from given directories. There is also a specific method for searching the standard libraries (/NextLibrary, /LocalLibrary, ~/Libary). Files can be limited to particular extensions and can be returned with or without their full path and extension.
	
	To use this object inside of InterfaceBuilder, simply drag its icon from the palettes window into the suitcases window. Then drag in a browser and set its delegate to be the filenameList. Then enter something like "Fonts" in the libraries textfield or "/NextLibrary/Documentation" in the directories textfield, type in an extension if you like(font, slo, rtf, etc...) and test interface.
¬
Palettes Window
			
¬
Example inspector

¬
Resulting Browser(set filename list to be its delegate)

Instance Variables

	char	*plLibs;				// Libary directories to be preloaded
	char	*plDirs;				// Directories to be preloaded
	char	*plExts;				// Extensions to be preloaded
	BOOL	plFromAppDir;			// Whether to preload from the AppWrapper
	BOOL	plFromBundleDir;			// Whether to preload from this bundle
	BOOL	plStripPath, plStripExt;		// Whether to strip paths & ext from files
	BOOL	plIfAbsent, plSorted;		// Whether to 'add if absent' and sort

Method Types

// Adding filenames
- addFilename:(const char *)filename stripPath:(BOOL)stripPath 
	stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy 
	sorted:(BOOL)sorted at:(int)at;

// Adding arrays of filenames or another PAFilenameList
- addFilenames:(const char *const*)filenames stripPath:(BOOL)stripPath 
	stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy 
	sorted:(BOOL)sorted at:(int)at;
- addPAFilenameList:filenameListObject stripPath:(BOOL)stripPath 
	stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy 
	sorted:(BOOL)sorted at:(int)at;

// Adding individual filenames from delimited (tab or otherwise) string
- addDelimitedFilenames:(const char *)string delimiters:(const char *)dels 
	stripPath:(BOOL)stripPath stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent 
	sorted:(BOOL)sorted at:(int)at;

// Adding filenames from directories
- addFilenamesFromDirectories:(const char *)dirs withExts:(const char *)exts 
	stripPath:(BOOL)stripPath stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent 
	sorted:(BOOL)sorted at:(int)at;
- addFilenamesFromStandardLibrariesDirectories:(const char *)dirs
	withExts:(const char *)exts stripPath:(BOOL)stripPath 
	stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent sorted:(BOOL)sorted 
	at:(int)at;

// Sorting Strings
- sortFilenamesIgnoringPath:sender;
int filenameCmp(const void *s1, const void *s2);

// Preloading strings
- (const char *)preLoadLibraries;
- setPreLoadLibraries:(const char *)libraries;

- (const char *)preLoadDirectories;
- setPreLoadDirectories:(const char *)directories;

- (const char *)preLoadExtensions;
- setPreLoadExtensions:(const char *)extensions;

- (BOOL)preLoadFromAppDir;
- setPreLoadFromAppDir:(BOOL)flag;

- (BOOL)preLoadFromBundleDir;
- setPreLoadFromBundleDir:(BOOL)flag;

- (BOOL)preLoadStripPath;
- setPreLoadStripPath:(BOOL)flag;

- (BOOL)preLoadStripExt;
- setPreLoadStripExt:(BOOL)flag;

- (BOOL)preLoadIfAbsent;
- setPreLoadIfAbsent:(BOOL)flag;

- (BOOL)preLoadSorted;
- setPreLoadSorted:(BOOL)flag;

// Archiving
- write:(NXTypedStream *)stream;
- read:(NXTypedStream *)stream;

Instance Methods

	addFilename:(char *)filename stripPath:(BOOL)stripPath 
		stripExt:(BOOL)stripExt ifAbsent:(BOOL)ifAbsent noCopy:(BOOL)noCopy 
		sorted:(BOOL)sorted at:(int)at

	This method adds the given filename to the list of strings giving the option to strip the path and/or the extension. It simply does the requested strips and calls addString:ifAbsent:noCopy:sorted:at:(PAStringList). Returns the value of that method (self).

	addFilenames:(char **)filenames stripPath:(BOOL)stripPath ...
	addPAFilenameList:filenameList stripPath:(BOOL)stripPath...

	These methods allow for lists of strings to be added as filenames (with or without their full paths and extensions).
	addFilename: adds filenames from a NULL terminated array of char pointers. Returns self.
	addPAFilenameList: add filenames from a PAFilenameList. Returns self.

	addFilenamesFromDirectories:withExts:

	addFilenamesFromDirectories looks out in the directories specified for files with the given extensions (NULL for all files) and adds them to the list. 'directory' is a delimited list of directories and 'ext' is a delimited list of extensions. Assumed delimiters are space, tab, newline, return, colon and comma (' ', '\t', '\n', '\r', ':', ',', '\0'). Returns self.
	addFilenamesFromStandardLibrariesDirectory goes a step farther and looks in /NextLibary, /LocalLibrary and ~/Libary for the given directories. This is a convenience for the cases where an app searches the standard libraries. Returns self.

	addDelimitedFilenames:delimiters:stripPath:stripExt:ifAbsent:sorted:at:at

	This method is just like addDelimitedStrings: but it allows the filnames to be stripped of their paths and/or extensions before being added. Returns self.

	sortFilenameIgnoringPath:

	sortFilenamesIgnoringPath: is just like sortStrings except that the full paths are stripped from the file before it is compared. This is useful for cases where you want the files to be in alphabetical order regardless of their full path, while preserving the full path. Returns self.

	(const char *)preLoadLibraries, setPreLoadLibraries:(const char *)libs
	(const char *)preLoadDirectories, setPreLoadDirectories:(const char *)dirs
	(const char *)preLoadExtensions, setPreLoadExtensions:(const char *)exts
	(BOOL)preLoadFromAppDir, setPreLoadFromAppDir:(BOOL)flag
	(BOOL)preLoadFromBundleDir, setPreLoadFromBundleDir:(BOOL)flag
	(BOOL)preLoadStripPath, setPreLoadStripPath:(BOOL)flag
	(BOOL)preLoadStripExt, setPreLoadStripExt:(BOOL)flag
	(BOOL)preLoadIfAbsent, setPreLoadIfAbsent:(BOOL)flag
	(BOOL)preLoadSorted, setPreLoadSorted:(BOOL)flag

	These methods query and set search paths, extensions and flags to preload the string list when unarchived. This allows for an InterfaceBuilder palette to set the StringList to load interesting things when unarchived (ie, "get all of the files of type 'font' from the standard library directory 'Fonts' ").

Copyright 1992, Jeff Martin (jmartin@next.com)